package com.framework.modules.base.dao;

import com.framework.modules.base.entity.UserDoingEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户行为表 
 * 
 * @author MIT
 * @email litmiss@gmail.com
 * @date 2020-10-23 15:11:22
 */
public interface UserDoingDao extends BaseMapper<UserDoingEntity> {

    @Delete("delete from tb_user_doing where uid=#{uid} and type=#{type} and object_name=#{objectName} and object_id=#{objectId} and object_uid=#{objectUid}")
    Integer deleteDoing(UserDoingEntity entity);

    /**
     *
     * @return
     */
    @Select("select * from tb_user_doing where uid=#{uid} and type=#{type} and object_name=#{objectName} and object_id=#{objectId} and object_uid=#{objectUid}")
    List<UserDoingEntity> listUserDoing(UserDoingEntity entity);

    /**
     * 获取我喜欢的人uid
     * @param uid
     * @return
     */
    @Select("select ud.object_uid from tb_user_doing ud where uid=#{uid} and type='like' and object_name='user'")
    List<String> getMyLikeUserUid(Integer uid);

    /**
     * 获取我关注的人uid
     * @param uid
     * @return
     */
    @Select("select ud.object_uid from tb_user_doing ud where uid=#{uid} and type='attent' and object_name='user'")
    List<String> getMyAttentUserUid(Integer uid);

    /**
     * 获取喜欢我的人uid
     * @param uid
     * @return
     */
    @Select("select ud.uid from tb_user_doing ud where ud.object_uid=#{uid} and ud.type='like' and ud.object_name='user'")
    List<String> getLikeMeUserUid(Integer uid);
	
}
